﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KeyboardBubble.Common
{
    public class FileHelp
    {
        // 读取当前目录下的文本文件
        public static List<string> ReadKeymapFile(string fileName)
        {
            List<string> lines = new List<string>();
            try
            {
                // 使用StreamReader逐行读取文件
                using (StreamReader reader = new StreamReader(Path.Combine(Directory.GetCurrentDirectory() + "/keymaps", fileName)))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        // 将每行数据添加到List中
                        lines.Add(line);
                    }
                }
            }
            catch (IOException e)
            {
                // 处理文件读取异常
                Console.WriteLine("读取快捷键映射配置错误: " + e.Message);
            }
            return lines;
        }
    }
}
